<?php

Raise::load('core.RaisePoint');

/**
 * TestCoreRaisePoint class
 * Testing unit of 'phpraise/core/RaisePoint.php'
 *
 * @author Sam-Mauris Yong <hellclanner at live dot com>
 * @license http://www.opensource.org/licenses/bsd-license New BSD License
 * @package Raise.UnitTest.Test
 */
class TestCoreRaisePoint extends RaiseTest{

    public static function testClass(){
        self::assertClassExists('RaisePoint');
        self::assertClassExtends('RaisePoint', 'RaiseDataType');

        $p = new RaisePoint(20, 30);
        self::assertStrictEqual($p->x(), 20);
        self::assertStrictEqual($p->y(), 30);
        self::assertNotEqual($p->x(), 50);
        self::assertNotEqual($p->y(), 20);

        self::assertObjectClass(RaisePoint::zero(), 'RaisePoint');
        self::assertStrictEqual(RaisePoint::zero()->x(), 0);
        self::assertStrictEqual(RaisePoint::zero()->y(), 0);
        self::assertTrue(RaisePoint::zero()->equals(RaisePoint::zero()));
        self::assertFalse(RaisePoint::zero()->equals($p));
    }
    
    public static function testToArray(){
        $p = new RaisePoint(20, 30);
        self::assertType($p->toArray(), 'array');
        self::assertStrictEqual($p->toArray(), array(20, 30));
    }

    public static function testEquals(){
        $p1 = new RaisePoint(20, 30);
        $p2 = new RaisePoint(20, 51);
        $p3 = new RaisePoint(20, 30);

        self::assertTrue($p1->equals($p3));
        self::assertFalse($p1->equals($p2));
        self::assertFalse($p2->equals($p3));
    }
}

